import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../routes/app_pages.dart';
import '../websocket_controller.dart';
import 'custom_avatar.dart';


class Menu extends GetView<WebsocketController> {
  const Menu({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Column(
            children: [
              const SizedBox(
                height: 30,
              ),
              CustomAvatar(
                avatar: controller.avatar,
              ),
              const SizedBox(
                height: 30,
              ),
              Text(
                controller.nickname,
                style: const TextStyle(
                  color: Colors.white,
                  fontSize: 18,
                  fontWeight: FontWeight.bold,
                ),
              ),
              GestureDetector(
                onTap: () {
                  Get.toNamed(Routes.HISTORY);
                },
                child: Container(
                  margin: const EdgeInsets.only(top: 10, left: 4),
                  height: 40,
                  decoration: BoxDecoration(
                      // color: const Color.fromARGB(255, 39, 37, 37),
                      border: Border.all(
                        color: Colors.white,
                      )),
                  child: const Center(
                    child: Text(
                      '历史对话',
                      style: TextStyle(
                          color: Colors.white, fontWeight: FontWeight.bold),
                    ),
                  ),
                ),
              ),
            ],
          ),
          GestureDetector(
            onTap: () {
              controller.logout();
            },
            child: Container(
              decoration: BoxDecoration(
                border: Border.all(
                  color: Colors.white,
                  width: 2,
                ),
              ),
              padding: const EdgeInsets.only(
                bottom: 12,
                top: 12,
              ),
              margin: const EdgeInsets.only(
                left: 10,
                bottom: 10,
              ),
              child: const Center(
                child: Text(
                  '退出登录',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
